﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for DBArticles
/// </summary>

public class DBArticles
{
    private List<Article> _articles = new List<Article>();
    public List<Article> Articles
    {
        get
        {
            return _articles;
        }
        set
        {
            _articles = value;
        }
    }

	public DBArticles()
	{
	}

    public void AddArticle(Article article)
    {
        _articles.Add(article);
    }

    public void ClearArticles()
    {
        _articles.Clear();
    }

    public void GetArticle()
    {
        //List<string> art = new List<string>();

        //for (int i = 0; i < _articles.Count; i++)
        //{
        //    art.Add(_articles.ElementAt(i).Title);
        //    art.Add(_articles.ElementAt(i).Description);
        //    art.Add(_articles.ElementAt(i).Image);
        //}

        //return art;
    }

    public Article GetArticleByTitle(string title)
    {
        Article art = null;

        for (int i = 0; i < _articles.Count; i++)
        {
            if (_articles.ElementAt(i).Title == title)
            {
                art = _articles.ElementAt(i);
            }
        }

        return art;
    }

    public List<string> GetArticlesTitles()
    {
        List<string> titles = new List<string>();

        for (int i = 0; i < _articles.Count; i++)
        {
            titles.Add(_articles.ElementAt(i).Title);
        }

        return titles;
    }

    public Article GetArticleByID(int id)
    {
        Article art = null;

        for (int i = 0; i < _articles.Count; i++)
        {
            if (_articles.ElementAt(i).ArticleID == id)
            {
                art = _articles.ElementAt(i);
            }
        }

        return art;
    }

    public List<int> GetArticlesID()
    {
        List<int> IDs = new List<int>();

        for (int i = 0; i < _articles.Count; i++)
        {
            IDs.Add(_articles.ElementAt(i).ArticleID);
        }

        return IDs;
    }

    public Article GetArticleByInsertDate(DateTime date)
    {
        Article art = null;

        for (int i = 0; i < _articles.Count; i++)
        {
            if (_articles.ElementAt(i).InsertDate == date)
            {
                art = _articles.ElementAt(i);
            }
        }

        return art;
    }

    public List<DateTime> GetArticlesInsertDate()
    {
        List<DateTime> InsertDates = new List<DateTime>();

        for (int i = 0; i < _articles.Count; i++)
        {
            InsertDates.Add(_articles.ElementAt(i).InsertDate);
        }

        return InsertDates;
    }
}